package cn.dengta.webapp.user.entity.activity;

import java.math.BigDecimal;

import cn.dengta.webapp.base.entity.TimeBasedEntity;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import me.codeplayer.util.Cmp;

/**
 * 足球比赛场次
 *
 * @author Ready
 * @since 2022-11-17
 */
@Setter
@Getter
@Accessors(chain = true)
@TableName("act_football_site")
public class ActFootballSite extends TimeBasedEntity {

	private static final long serialVersionUID = 1L;

	/** 赛事时间点 */
	Long eventTime;
	/** 主场编码 */
	Long masterCode;
	/** 客场编码 */
	Long guestCode;
	/** 主场赔率 */
	BigDecimal masterRatio;
	/** 客场赔率 */
	BigDecimal guestRatio;
	/** 和赔率 */
	BigDecimal flatRatio;
	/** 赢比赛的类型： 1=主场赢；2=客场赢；3=平局 */
	Integer winType;
	/** 收入金币 */
	Integer income;
	/** 支出金币 */
	Integer spending;
	/** 0=未开始；1=进行中；2=已结束；3=开奖中；4=已开奖 */
	Integer status;

	public static final String EVENT_TIME = "event_time";
	public static final String MASTER_CODE = "master_code";
	public static final String GUEST_CODE = "guest_code";
	public static final String MASTER_RATIO = "master_ratio";
	public static final String GUEST_RATIO = "guest_ratio";
	public static final String FLAT_RATIO = "flat_ratio";
	public static final String STATUS = "status";

	public boolean canBet() {
		return Cmp.eq(this.status, 0) && eventTime > System.currentTimeMillis() + duration;
	}

	private static long duration = 10 * 60 * 1000;

	/** 是否结束 */
	public boolean hasEnd() {
		return Cmp.ge(this.status, 2);
	}

}
